/**
 * AI对话页面样式
 */

* {
  font-family: 'STKaiti', 'KaiTi', serif;
}

.chat-container {
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background: linear-gradient(180deg, #f5f0e8 0%, #faf8f3 100%);
  position: relative;
  padding-bottom: 160px;
  box-sizing: border-box;
}

/* 文物信息卡片 */
.artifact-card {
  background: linear-gradient(135deg, #B8956A 0%, #A5875F 100%);
  padding: clamp(15px, 4vw, 30px);
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 20px);
  box-shadow: 0 4px 12px rgba(140, 110, 75, 0.2);
  position: relative;
  flex-wrap: nowrap;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
      repeating-linear-gradient(45deg, transparent, transparent 35px, rgba(255,255,255,.05) 35px, rgba(255,255,255,.05) 70px);
    pointer-events: none;
  }
}

.artifact-icon {
  font-size: clamp(48px, 10vw, 80px);
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.artifact-card-info {
  flex: 1;
  position: relative;
  z-index: 2;
  min-width: 0;
}

.artifact-card-name {
  display: block;
  font-size: clamp(18px, 4vw, 32px);
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
  letter-spacing: 0.1em;
  font-family: 'STKaiti', 'KaiTi', serif;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-card-dynasty {
  display: block;
  font-size: clamp(14px, 3vw, 24px);
  color: rgba(255, 255, 255, 0.8);
}

// 清空聊天按钮
.clear-button {
  margin-left: auto;
  padding: clamp(8px, 2vw, 10px);
  background: rgba(255, 68, 68, 0.15);
  border-radius: clamp(8px, 2vw, 10px);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 2;
  position: relative;
  
  &:active {
    transform: scale(0.92);
    background: rgba(255, 68, 68, 0.25);
  }
}

.clear-icon {
  font-size: clamp(18px, 4.5vw, 24px);
}

/* 消息列表 */
.messages-scroll {
  width: 100%;
  padding: clamp(15px, 3vw, 30px);
  min-height: 300px;
}

.messages-list {
  width: 100%;
  padding-bottom: 30px;
}

.message-item {
  display: flex;
  gap: clamp(10px, 2vw, 16px);
  margin-bottom: clamp(20px, 4vw, 30px);
  animation: messageSlideIn 0.3s ease;
  flex-wrap: nowrap;
  
  &.user {
    flex-direction: row;          // 保持正常顺序
    justify-content: flex-end;    // 整体靠右对齐
    
    .message-avatar {
      // 用户头像样式强化（在消息气泡右边）
      background: linear-gradient(135deg, #8C6E4B 0%, #6B5438 100%);
      box-shadow: 0 2px 8px rgba(140, 110, 75, 0.3);
    }
    
    .message-content {
      background: linear-gradient(135deg, #B8956A 0%, #A5875F 100%);
      
      .message-text {
        color: #fff;
        text-align: left;  // 文字左对齐
      }
      
      .message-time {
        color: rgba(255, 255, 255, 0.8);
        text-align: right;
      }
    }
  }
  
  &.assistant {
    justify-content: flex-start;  // 整体靠左对齐
    
    .message-avatar {
      // 助手头像样式（在消息气泡左边）
      background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .message-content {
      background: #fff;
      box-shadow: 0 2px 12px rgba(139, 69, 19, 0.08);
    }
  }
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-avatar {
  width: clamp(44px, 9vw, 70px);
  height: clamp(44px, 9vw, 70px);
  min-width: 44px;  // 确保最小宽度
  min-height: 44px; // 确保最小高度
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;  // 确保内容不被裁剪
  transition: transform 0.2s ease;
  
  &:active {
    transform: scale(0.95);
  }
}

.avatar-text {
  font-size: clamp(22px, 4.5vw, 36px);
  line-height: 1;  // 确保行高不会超出容器
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-content {
  flex: 1;
  padding: clamp(12px, 3vw, 20px) clamp(15px, 3.5vw, 24px);
  border-radius: clamp(10px, 2vw, 16px);
  max-width: 70%;
  min-width: 0;
  overflow: visible;  // 确保内容不被裁剪
}

/* 思考过程 */
.message-reasoning {
  background: linear-gradient(135deg, #f5f0e8 0%, #faf8f3 100%);
  border-left: 3px solid #B8956A;
  padding: clamp(10px, 2.5vw, 16px);
  border-radius: clamp(8px, 1.5vw, 12px);
  margin-bottom: clamp(12px, 2.5vw, 16px);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.reasoning-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  padding-bottom: 4px;
  
  &:active {
    opacity: 0.7;
  }
}

.reasoning-title {
  font-size: clamp(12px, 3vw, 24px);
  font-weight: 600;
  color: #B8956A;
  flex: 1;
}

.reasoning-toggle {
  font-size: clamp(11px, 2.8vw, 22px);
  color: #B8956A;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(184, 149, 106, 0.1);
  transition: all 0.2s ease;
  
  &:active {
    background: rgba(184, 149, 106, 0.2);
  }
}

.reasoning-text {
  display: block;
  font-size: clamp(12px, 3vw, 24px);
  line-height: 1.6;
  color: #666;
  word-wrap: break-word;
  white-space: pre-wrap;
  font-style: italic;
  opacity: 0.9;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(184, 149, 106, 0.3);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 0.9;
    transform: translateY(0);
  }
}

.message-text {
  display: block;
  font-size: clamp(14px, 3.5vw, 28px);
  line-height: 1.6;
  color: #333;
  word-wrap: break-word;
  white-space: pre-wrap;
  margin-bottom: 6px;
}

.message-time {
  display: block;
  font-size: clamp(12px, 2.5vw, 22px);
  color: #999;
}

/* 加载指示器 */
.typing-indicator {
  display: flex;
  gap: 8px;
  padding: 10px 0;
}

.typing-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #B8956A;
  animation: typingBounce 1.4s infinite;
  
  &:nth-child(1) {
    animation-delay: 0s;
  }
  
  &:nth-child(2) {
    animation-delay: 0.2s;
  }
  
  &:nth-child(3) {
    animation-delay: 0.4s;
  }
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* 输入区域 */
.input-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  padding: clamp(15px, 3vw, 20px) clamp(20px, 4vw, 30px);
  border-top: 1px solid #e0e0e0;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  z-index: 100;
}

.input-wrapper {
  display: flex;
  gap: clamp(12px, 2.5vw, 16px);
  align-items: center;
}

.chat-input {
  flex: 1;
  background: #f5f5f5;
  border-radius: clamp(20px, 4vw, 24px);
  padding: clamp(14px, 3vw, 20px) clamp(18px, 3.5vw, 24px);
  font-size: clamp(14px, 3.5vw, 28px);
  color: #333;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  line-height: 1.4;
  
  &:focus {
    background: #fff;
    border-color: #B8956A;
  }
}

.send-button {
  background: linear-gradient(135deg, #B8956A 0%, #A5875F 100%);
  padding: clamp(14px, 3vw, 20px) clamp(24px, 4.5vw, 32px);
  border-radius: clamp(20px, 4vw, 24px);
  box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
  transition: all 0.2s ease;
  flex-shrink: 0;
  
  &:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(139, 69, 19, 0.3);
  }
  
  &.disabled {
    opacity: 0.5;
    pointer-events: none;
  }
}

.send-button-text {
  font-size: clamp(14px, 3.5vw, 28px);
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

/* 加载状态 */
.loading-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-text {
  font-size: 28px;
  color: #999;
}

